﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a drawing object.</summary>
	// Token: 0x02000036 RID: 54
	public class HDrawingObject : HHandle
	{
		// Token: 0x060004DE RID: 1246 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDrawingObject() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x060004DF RID: 1247 RVA: 0x0001CAAD File Offset: 0x0001ACAD
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDrawingObject(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060004E0 RID: 1248 RVA: 0x0001CABC File Offset: 0x0001ACBC
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDrawingObject(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060004E1 RID: 1249 RVA: 0x0001CACB File Offset: 0x0001ACCB
		private void AssertSemType()
		{
			base.AssertSemType("drawing_object");
		}

		// Token: 0x060004E2 RID: 1250 RVA: 0x0001CAD8 File Offset: 0x0001ACD8
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDrawingObject obj)
		{
			obj = new HDrawingObject(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x060004E3 RID: 1251 RVA: 0x0001CAF0 File Offset: 0x0001ACF0
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDrawingObject[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HDrawingObject[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HDrawingObject(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Create a circle which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row coordinate of the center. Default: 100</param>
		/// <param name="column">Column coordinate of the center. Default: 100</param>
		/// <param name="radius">Radius of the circle. Default: 80</param>
		// Token: 0x060004E4 RID: 1252 RVA: 0x0001CB60 File Offset: 0x0001AD60
		public HDrawingObject(double row, double column, double radius)
		{
			IntPtr proc = HalconAPI.PreCall(1311);
			HalconAPI.StoreD(proc, 0, row);
			HalconAPI.StoreD(proc, 1, column);
			HalconAPI.StoreD(proc, 2, radius);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a rectangle of any orientation which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row coordinate of the center. Default: 150</param>
		/// <param name="column">Column coordinate of the center. Default: 150</param>
		/// <param name="phi">Orientation of the first half axis in radians. Default: 0</param>
		/// <param name="length1">First half axis. Default: 100</param>
		/// <param name="length2">Second half axis. Default: 100</param>
		// Token: 0x060004E5 RID: 1253 RVA: 0x0001CBBC File Offset: 0x0001ADBC
		public HDrawingObject(double row, double column, double phi, double length1, double length2)
		{
			IntPtr proc = HalconAPI.PreCall(1313);
			HalconAPI.StoreD(proc, 0, row);
			HalconAPI.StoreD(proc, 1, column);
			HalconAPI.StoreD(proc, 2, phi);
			HalconAPI.StoreD(proc, 3, length1);
			HalconAPI.StoreD(proc, 4, length2);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a rectangle parallel to the coordinate axis which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row1">Row coordinate of the upper left corner. Default: 100</param>
		/// <param name="column1">Column coordinate of the upper left corner. Default: 100</param>
		/// <param name="row2">Row coordinate of the lower right corner. Default: 200</param>
		/// <param name="column2">Column coordinate of the lower right corner. Default: 200</param>
		// Token: 0x060004E6 RID: 1254 RVA: 0x0001CC2C File Offset: 0x0001AE2C
		public HDrawingObject(double row1, double column1, double row2, double column2)
		{
			IntPtr proc = HalconAPI.PreCall(1314);
			HalconAPI.StoreD(proc, 0, row1);
			HalconAPI.StoreD(proc, 1, column1);
			HalconAPI.StoreD(proc, 2, row2);
			HalconAPI.StoreD(proc, 3, column2);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>Returns the corresponding HALCON id.</summary>
		// Token: 0x17000049 RID: 73
		// (get) Token: 0x060004E7 RID: 1255 RVA: 0x0001CC94 File Offset: 0x0001AE94
		public long ID
		{
			get
			{
				return base.Handle.ToInt64();
			}
		}

		// Token: 0x060004E8 RID: 1256 RVA: 0x0001CCAF File Offset: 0x0001AEAF
		protected IntPtr DelegateToCallbackPointer(HDrawingObject.HDrawingObjectCallback c)
		{
			return Marshal.GetFunctionPointerForDelegate(c);
		}

		// Token: 0x060004E9 RID: 1257 RVA: 0x0001CCB8 File Offset: 0x0001AEB8
		protected IntPtr DelegateToCallbackPointer(HDrawingObject.HDrawingObjectCallbackClass c, string evt)
		{
			HDrawingObject.HDrawingObjectCallback hdrawingObjectCallback = delegate(IntPtr drawid, IntPtr window, string type)
			{
				HDrawingObject hdrawingObject = new HDrawingObject(drawid);
				HWindow hwindow = new HWindow(window);
				hdrawingObject.Detach();
				hwindow.Detach();
				c(hdrawingObject, hwindow, type);
			};
			GC.KeepAlive(hdrawingObjectCallback);
			GC.SuppressFinalize(hdrawingObjectCallback);
			if (!(evt == "on_resize"))
			{
				if (!(evt == "on_attach"))
				{
					if (!(evt == "on_detach"))
					{
						if (!(evt == "on_drag"))
						{
							if (evt == "on_select")
							{
								this.onselect = hdrawingObjectCallback;
							}
						}
						else
						{
							this.ondrag = hdrawingObjectCallback;
						}
					}
					else
					{
						this.ondetach = hdrawingObjectCallback;
					}
				}
				else
				{
					this.onattach = hdrawingObjectCallback;
				}
			}
			else
			{
				this.onresize = hdrawingObjectCallback;
			}
			return Marshal.GetFunctionPointerForDelegate(hdrawingObjectCallback);
		}

		/// <summary>Adds a callback for the resize event, that is, this callback is
		/// executed whenever the user changes any of the dimensions of the draw 
		/// object.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004EA RID: 1258 RVA: 0x0001CD5D File Offset: 0x0001AF5D
		public void OnResize(HDrawingObject.HDrawingObjectCallback f)
		{
			this.SetDrawingObjectCallback("on_resize", Marshal.GetFunctionPointerForDelegate(f));
		}

		/// <summary>Adds a callback for the attach event, that is, this callback is
		/// executed when a drawing object is attached to the window.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004EB RID: 1259 RVA: 0x0001CD70 File Offset: 0x0001AF70
		public void OnAttach(HDrawingObject.HDrawingObjectCallback f)
		{
			this.SetDrawingObjectCallback("on_attach", Marshal.GetFunctionPointerForDelegate(f));
		}

		/// <summary>Adds a callback for the detach event, that is, this callback is
		/// executed when a drawing object is detached from the window.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004EC RID: 1260 RVA: 0x0001CD83 File Offset: 0x0001AF83
		public void OnDetach(HDrawingObject.HDrawingObjectCallback f)
		{
			this.SetDrawingObjectCallback("on_detach", Marshal.GetFunctionPointerForDelegate(f));
		}

		/// <summary>Adds a callback for the resize event, that is, this callback is
		/// executed whenever the drawing object's position changes.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004ED RID: 1261 RVA: 0x0001CD96 File Offset: 0x0001AF96
		public void OnDrag(HDrawingObject.HDrawingObjectCallback f)
		{
			this.SetDrawingObjectCallback("on_drag", Marshal.GetFunctionPointerForDelegate(f));
		}

		/// <summary>Adds a callback for the resize event, that is, this callback is
		/// executed whenever the drawing object is selected.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004EE RID: 1262 RVA: 0x0001CDA9 File Offset: 0x0001AFA9
		public void OnSelect(HDrawingObject.HDrawingObjectCallback f)
		{
			this.SetDrawingObjectCallback("on_select", Marshal.GetFunctionPointerForDelegate(f));
		}

		/// <summary>Adds a callback for the resize event, that is, this callback is
		/// executed whenever the user changes any of the dimensions of the draw 
		/// object.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004EF RID: 1263 RVA: 0x0001CDBC File Offset: 0x0001AFBC
		public void OnResize(HDrawingObject.HDrawingObjectCallbackClass f)
		{
			this.SetDrawingObjectCallback("on_resize", this.DelegateToCallbackPointer(f, "on_resize"));
		}

		/// <summary>Adds a callback for the resize event, that is, this callback is
		/// executed whenever the drawing object's position changes.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004F0 RID: 1264 RVA: 0x0001CDD5 File Offset: 0x0001AFD5
		public void OnDrag(HDrawingObject.HDrawingObjectCallbackClass f)
		{
			this.SetDrawingObjectCallback("on_drag", this.DelegateToCallbackPointer(f, "on_drag"));
		}

		/// <summary>Adds a callback for the resize event, that is, this callback is
		/// executed whenever the drawing object is selected.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004F1 RID: 1265 RVA: 0x0001CDEE File Offset: 0x0001AFEE
		public void OnSelect(HDrawingObject.HDrawingObjectCallbackClass f)
		{
			this.SetDrawingObjectCallback("on_select", this.DelegateToCallbackPointer(f, "on_select"));
		}

		/// <summary>Adds a callback for the attach event, that is, this callback is
		/// executed when a drawing object is attached to the window.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004F2 RID: 1266 RVA: 0x0001CE07 File Offset: 0x0001B007
		public void OnAttach(HDrawingObject.HDrawingObjectCallbackClass f)
		{
			this.SetDrawingObjectCallback("on_attach", this.DelegateToCallbackPointer(f, "on_attach"));
		}

		/// <summary>Adds a callback for the detach event, that is, this callback is
		/// executed when a drawing object is detached from the window.</summary>
		/// <param name="f">Callback function with the signature defined by 
		/// HDrawingObjectCallback</param>
		// Token: 0x060004F3 RID: 1267 RVA: 0x0001CE20 File Offset: 0x0001B020
		public void OnDetach(HDrawingObject.HDrawingObjectCallbackClass f)
		{
			this.SetDrawingObjectCallback("on_detach", this.DelegateToCallbackPointer(f, "on_detach"));
		}

		/// <summary>Method to create drawing objects by explicitly specifying the type.</summary>
		/// <param name="type">Type of the drawing object. Can be any of the specified by
		///  the enum type HDrawingObjectType.</param>
		/// <param name="values"> List of parameters for the corresponding drawing object.
		/// See the constructors listed in HOperatorSet for more details.</param>
		// Token: 0x060004F4 RID: 1268 RVA: 0x0001CE3C File Offset: 0x0001B03C
		public static HDrawingObject CreateDrawingObject(HDrawingObject.HDrawingObjectType type, params HTuple[] values)
		{
			HDrawingObject hdrawingObject = new HDrawingObject();
			switch (type)
			{
			case HDrawingObject.HDrawingObjectType.RECTANGLE1:
				hdrawingObject.CreateDrawingObjectRectangle1(values[0], values[1], values[2], values[3]);
				break;
			case HDrawingObject.HDrawingObjectType.RECTANGLE2:
				hdrawingObject.CreateDrawingObjectRectangle2(values[0], values[1], values[2], values[3], values[4]);
				break;
			case HDrawingObject.HDrawingObjectType.CIRCLE:
				hdrawingObject.CreateDrawingObjectCircle(values[0], values[1], values[2]);
				break;
			case HDrawingObject.HDrawingObjectType.ELLIPSE:
				hdrawingObject.CreateDrawingObjectEllipse(values[0], values[1], values[2], values[3], values[4]);
				break;
			case HDrawingObject.HDrawingObjectType.CIRCLE_SECTOR:
				hdrawingObject.CreateDrawingObjectCircleSector(values[0], values[1], values[2], values[3], values[4]);
				break;
			case HDrawingObject.HDrawingObjectType.ELLIPSE_SECTOR:
				hdrawingObject.CreateDrawingObjectEllipseSector(values[0], values[1], values[2], values[3], values[4], values[5], values[6]);
				break;
			case HDrawingObject.HDrawingObjectType.LINE:
				hdrawingObject.CreateDrawingObjectLine(values[0], values[1], values[2], values[3]);
				break;
			case HDrawingObject.HDrawingObjectType.XLD_CONTOUR:
				if (values.Length != 2)
				{
					throw new HalconException("Invalid number of parameters");
				}
				if (values[0].Length != values[1].Length)
				{
					throw new HalconException("The length of the input tuples must be identical");
				}
				hdrawingObject.CreateDrawingObjectXld(values[0].DArr, values[1].DArr);
				break;
			case HDrawingObject.HDrawingObjectType.TEXT:
				hdrawingObject.CreateDrawingObjectText(values[0], values[1], values[2]);
				break;
			}
			return hdrawingObject;
		}

		/// <summary>
		///   Add a callback function to a drawing object.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="drawObjectEvent">Events to be captured.</param>
		/// <param name="callbackFunction">Callback functions.</param>
		// Token: 0x060004F5 RID: 1269 RVA: 0x0001D040 File Offset: 0x0001B240
		public void SetDrawingObjectCallback(HTuple drawObjectEvent, HTuple callbackFunction)
		{
			IntPtr proc = HalconAPI.PreCall(1162);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, drawObjectEvent);
			HalconAPI.Store(proc, 2, callbackFunction);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(drawObjectEvent);
			HalconAPI.UnpinTuple(callbackFunction);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Add a callback function to a drawing object.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="drawObjectEvent">Events to be captured.</param>
		/// <param name="callbackFunction">Callback functions.</param>
		// Token: 0x060004F6 RID: 1270 RVA: 0x0001D090 File Offset: 0x0001B290
		public void SetDrawingObjectCallback(string drawObjectEvent, IntPtr callbackFunction)
		{
			IntPtr proc = HalconAPI.PreCall(1162);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, drawObjectEvent);
			HalconAPI.StoreIP(proc, 2, callbackFunction);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>Detach the background image from a HALCON window.</summary>
		/// <param name="windowHandle">Window handle.</param>
		// Token: 0x060004F7 RID: 1271 RVA: 0x0001D0D4 File Offset: 0x0001B2D4
		public static void DetachBackgroundFromWindow(HWindow windowHandle)
		{
			IntPtr proc = HalconAPI.PreCall(1163);
			HalconAPI.Store(proc, 0, windowHandle);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(windowHandle);
		}

		/// <summary>Attach a background image to a HALCON window.</summary>
		/// <param name="image">Background image.</param>
		/// <param name="windowHandle">Window handle.</param>
		// Token: 0x060004F8 RID: 1272 RVA: 0x0001D108 File Offset: 0x0001B308
		public static void AttachBackgroundToWindow(HImage image, HWindow windowHandle)
		{
			IntPtr proc = HalconAPI.PreCall(1164);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.Store(proc, 0, windowHandle);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(image);
			GC.KeepAlive(windowHandle);
		}

		/// <summary>
		///   Create a text object which can be moved interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row coordinate of the text position. Default: 12</param>
		/// <param name="column">Column coordinate of the text position. Default: 12</param>
		/// <param name="stringVal">Character string to be displayed. Default: "Text"</param>
		// Token: 0x060004F9 RID: 1273 RVA: 0x0001D148 File Offset: 0x0001B348
		public void CreateDrawingObjectText(int row, int column, string stringVal)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1301);
			HalconAPI.StoreI(proc, 0, row);
			HalconAPI.StoreI(proc, 1, column);
			HalconAPI.StoreS(proc, 2, stringVal);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Return the iconic object of a drawing object.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		/// <returns>Copy of the iconic object represented by the drawing object.</returns>
		// Token: 0x060004FA RID: 1274 RVA: 0x0001D1A4 File Offset: 0x0001B3A4
		public HObject GetDrawingObjectIconic()
		{
			IntPtr proc = HalconAPI.PreCall(1302);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HObject result;
			num = HObject.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Delete drawing object.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		// Token: 0x060004FB RID: 1275 RVA: 0x0001D1EC File Offset: 0x0001B3EC
		public void ClearDrawingObject()
		{
			IntPtr proc = HalconAPI.PreCall(1303);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set the parameters of a drawing object.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="genParamName">Parameter names of the drawing object.</param>
		/// <param name="genParamValue">Parameter values.</param>
		// Token: 0x060004FC RID: 1276 RVA: 0x0001D220 File Offset: 0x0001B420
		public void SetDrawingObjectParams(HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1304);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set the parameters of a drawing object.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="genParamName">Parameter names of the drawing object.</param>
		/// <param name="genParamValue">Parameter values.</param>
		// Token: 0x060004FD RID: 1277 RVA: 0x0001D270 File Offset: 0x0001B470
		public void SetDrawingObjectParams(string genParamName, double genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1304);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreD(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Get the parameters of a drawing object.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="genParamName">Parameter names of the drawing object.</param>
		/// <returns>Parameter values.</returns>
		// Token: 0x060004FE RID: 1278 RVA: 0x0001D2B4 File Offset: 0x0001B4B4
		public HTuple GetDrawingObjectParams(HTuple genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(1305);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get the parameters of a drawing object.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="genParamName">Parameter names of the drawing object.</param>
		/// <returns>Parameter values.</returns>
		// Token: 0x060004FF RID: 1279 RVA: 0x0001D30C File Offset: 0x0001B50C
		public HTuple GetDrawingObjectParams(string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(1305);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Set the contour of an interactive draw XLD.
		///   Instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="contour">XLD contour.</param>
		// Token: 0x06000500 RID: 1280 RVA: 0x0001D35C File Offset: 0x0001B55C
		public void SetDrawingObjectXld(HXLDCont contour)
		{
			IntPtr proc = HalconAPI.PreCall(1306);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, contour);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
			GC.KeepAlive(contour);
		}

		/// <summary>
		///   Create a XLD contour which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row coordinates of the polygon. Default: [100,200,200,100]</param>
		/// <param name="column">Column coordinates of the polygon. Default: [100,100,200,200]</param>
		// Token: 0x06000501 RID: 1281 RVA: 0x0001D3A0 File Offset: 0x0001B5A0
		public void CreateDrawingObjectXld(HTuple row, HTuple column)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1307);
			HalconAPI.Store(proc, 0, row);
			HalconAPI.Store(proc, 1, column);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(row);
			HalconAPI.UnpinTuple(column);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a circle sector which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row coordinate of the center. Default: 100</param>
		/// <param name="column">Column coordinate of the center. Default: 100</param>
		/// <param name="radius">Radius of the circle. Default: 80</param>
		/// <param name="startAngle">Start angle of the arc. Default: 0</param>
		/// <param name="endAngle">End angle of the arc. Default: 3.14159</param>
		// Token: 0x06000502 RID: 1282 RVA: 0x0001D400 File Offset: 0x0001B600
		public void CreateDrawingObjectCircleSector(double row, double column, double radius, double startAngle, double endAngle)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1308);
			HalconAPI.StoreD(proc, 0, row);
			HalconAPI.StoreD(proc, 1, column);
			HalconAPI.StoreD(proc, 2, radius);
			HalconAPI.StoreD(proc, 3, startAngle);
			HalconAPI.StoreD(proc, 4, endAngle);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create an elliptic sector which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row index of the center. Default: 200</param>
		/// <param name="column">Column index of the center. Default: 200</param>
		/// <param name="phi">Orientation of the first half axis in radians. Default: 0</param>
		/// <param name="radius1">First half axis. Default: 100</param>
		/// <param name="radius2">Second half axis. Default: 60</param>
		/// <param name="startAngle">Start angle of the arc. Default: 0</param>
		/// <param name="endAngle">End angle of the arc. Default: 3.14159</param>
		// Token: 0x06000503 RID: 1283 RVA: 0x0001D470 File Offset: 0x0001B670
		public void CreateDrawingObjectEllipseSector(double row, double column, double phi, double radius1, double radius2, double startAngle, double endAngle)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1309);
			HalconAPI.StoreD(proc, 0, row);
			HalconAPI.StoreD(proc, 1, column);
			HalconAPI.StoreD(proc, 2, phi);
			HalconAPI.StoreD(proc, 3, radius1);
			HalconAPI.StoreD(proc, 4, radius2);
			HalconAPI.StoreD(proc, 5, startAngle);
			HalconAPI.StoreD(proc, 6, endAngle);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a line which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row1">Row coordinate of the first line point. Default: 100</param>
		/// <param name="column1">Column coordinate of the first line point. Default: 100</param>
		/// <param name="row2">Row coordinate of the second line point. Default: 200</param>
		/// <param name="column2">Column coordinate of the second line point. Default: 200</param>
		// Token: 0x06000504 RID: 1284 RVA: 0x0001D4F0 File Offset: 0x0001B6F0
		public void CreateDrawingObjectLine(double row1, double column1, double row2, double column2)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1310);
			HalconAPI.StoreD(proc, 0, row1);
			HalconAPI.StoreD(proc, 1, column1);
			HalconAPI.StoreD(proc, 2, row2);
			HalconAPI.StoreD(proc, 3, column2);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a circle which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row coordinate of the center. Default: 100</param>
		/// <param name="column">Column coordinate of the center. Default: 100</param>
		/// <param name="radius">Radius of the circle. Default: 80</param>
		// Token: 0x06000505 RID: 1285 RVA: 0x0001D558 File Offset: 0x0001B758
		public void CreateDrawingObjectCircle(double row, double column, double radius)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1311);
			HalconAPI.StoreD(proc, 0, row);
			HalconAPI.StoreD(proc, 1, column);
			HalconAPI.StoreD(proc, 2, radius);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create an ellipse which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row index of the center. Default: 200</param>
		/// <param name="column">Column index of the center. Default: 200</param>
		/// <param name="phi">Orientation of the first half axis in radians. Default: 0</param>
		/// <param name="radius1">First half axis. Default: 100</param>
		/// <param name="radius2">Second half axis. Default: 60</param>
		// Token: 0x06000506 RID: 1286 RVA: 0x0001D5B4 File Offset: 0x0001B7B4
		public void CreateDrawingObjectEllipse(double row, double column, double phi, double radius1, double radius2)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1312);
			HalconAPI.StoreD(proc, 0, row);
			HalconAPI.StoreD(proc, 1, column);
			HalconAPI.StoreD(proc, 2, phi);
			HalconAPI.StoreD(proc, 3, radius1);
			HalconAPI.StoreD(proc, 4, radius2);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a rectangle of any orientation which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row">Row coordinate of the center. Default: 150</param>
		/// <param name="column">Column coordinate of the center. Default: 150</param>
		/// <param name="phi">Orientation of the first half axis in radians. Default: 0</param>
		/// <param name="length1">First half axis. Default: 100</param>
		/// <param name="length2">Second half axis. Default: 100</param>
		// Token: 0x06000507 RID: 1287 RVA: 0x0001D624 File Offset: 0x0001B824
		public void CreateDrawingObjectRectangle2(double row, double column, double phi, double length1, double length2)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1313);
			HalconAPI.StoreD(proc, 0, row);
			HalconAPI.StoreD(proc, 1, column);
			HalconAPI.StoreD(proc, 2, phi);
			HalconAPI.StoreD(proc, 3, length1);
			HalconAPI.StoreD(proc, 4, length2);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a rectangle parallel to the coordinate axis which can be modified interactively.
		///   Modified instance represents: Handle of the drawing object.
		/// </summary>
		/// <param name="row1">Row coordinate of the upper left corner. Default: 100</param>
		/// <param name="column1">Column coordinate of the upper left corner. Default: 100</param>
		/// <param name="row2">Row coordinate of the lower right corner. Default: 200</param>
		/// <param name="column2">Column coordinate of the lower right corner. Default: 200</param>
		// Token: 0x06000508 RID: 1288 RVA: 0x0001D694 File Offset: 0x0001B894
		public void CreateDrawingObjectRectangle1(double row1, double column1, double row2, double column2)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1314);
			HalconAPI.StoreD(proc, 0, row1);
			HalconAPI.StoreD(proc, 1, column1);
			HalconAPI.StoreD(proc, 2, row2);
			HalconAPI.StoreD(proc, 3, column2);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>Send an event to a buffer window signaling a mouse double click event.</summary>
		/// <param name="windowHandle">Window handle of the buffer window.</param>
		/// <param name="row">Row coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="column">Column coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="button">Mouse button(s) pressed.</param>
		/// <returns>'true', if HALCON processed the event.</returns>
		// Token: 0x06000509 RID: 1289 RVA: 0x0001D6FC File Offset: 0x0001B8FC
		public static string SendMouseDoubleClickEvent(HWindow windowHandle, HTuple row, HTuple column, int button)
		{
			IntPtr proc = HalconAPI.PreCall(2088);
			HalconAPI.Store(proc, 0, windowHandle);
			HalconAPI.Store(proc, 1, row);
			HalconAPI.Store(proc, 2, column);
			HalconAPI.StoreI(proc, 3, button);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(row);
			HalconAPI.UnpinTuple(column);
			string result;
			num = HalconAPI.LoadS(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(windowHandle);
			return result;
		}

		/// <summary>Send an event to a buffer window signaling a mouse double click event.</summary>
		/// <param name="windowHandle">Window handle of the buffer window.</param>
		/// <param name="row">Row coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="column">Column coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="button">Mouse button(s) pressed.</param>
		/// <returns>'true', if HALCON processed the event.</returns>
		// Token: 0x0600050A RID: 1290 RVA: 0x0001D768 File Offset: 0x0001B968
		public static string SendMouseDoubleClickEvent(HWindow windowHandle, int row, int column, int button)
		{
			IntPtr proc = HalconAPI.PreCall(2088);
			HalconAPI.Store(proc, 0, windowHandle);
			HalconAPI.StoreI(proc, 1, row);
			HalconAPI.StoreI(proc, 2, column);
			HalconAPI.StoreI(proc, 3, button);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			string result;
			num = HalconAPI.LoadS(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(windowHandle);
			return result;
		}

		/// <summary>Send an event to a window buffer signaling a mouse down event.</summary>
		/// <param name="windowHandle">Window handle of the buffer window.</param>
		/// <param name="row">Row coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="column">Column coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="button">Mouse button(s) pressed.</param>
		/// <returns>'true', if HALCON processed the event.</returns>
		// Token: 0x0600050B RID: 1291 RVA: 0x0001D7C8 File Offset: 0x0001B9C8
		public static string SendMouseDownEvent(HWindow windowHandle, HTuple row, HTuple column, int button)
		{
			IntPtr proc = HalconAPI.PreCall(2089);
			HalconAPI.Store(proc, 0, windowHandle);
			HalconAPI.Store(proc, 1, row);
			HalconAPI.Store(proc, 2, column);
			HalconAPI.StoreI(proc, 3, button);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(row);
			HalconAPI.UnpinTuple(column);
			string result;
			num = HalconAPI.LoadS(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(windowHandle);
			return result;
		}

		/// <summary>Send an event to a window buffer signaling a mouse down event.</summary>
		/// <param name="windowHandle">Window handle of the buffer window.</param>
		/// <param name="row">Row coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="column">Column coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="button">Mouse button(s) pressed.</param>
		/// <returns>'true', if HALCON processed the event.</returns>
		// Token: 0x0600050C RID: 1292 RVA: 0x0001D834 File Offset: 0x0001BA34
		public static string SendMouseDownEvent(HWindow windowHandle, int row, int column, int button)
		{
			IntPtr proc = HalconAPI.PreCall(2089);
			HalconAPI.Store(proc, 0, windowHandle);
			HalconAPI.StoreI(proc, 1, row);
			HalconAPI.StoreI(proc, 2, column);
			HalconAPI.StoreI(proc, 3, button);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			string result;
			num = HalconAPI.LoadS(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(windowHandle);
			return result;
		}

		/// <summary>Send an event to a buffer window signaling a mouse drag event.</summary>
		/// <param name="windowHandle">Window handle of the buffer window.</param>
		/// <param name="row">Row coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="column">Column coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="button">Mouse button(s) pressed.</param>
		/// <returns>'true', if HALCON processed the event.</returns>
		// Token: 0x0600050D RID: 1293 RVA: 0x0001D894 File Offset: 0x0001BA94
		public static string SendMouseDragEvent(HWindow windowHandle, HTuple row, HTuple column, int button)
		{
			IntPtr proc = HalconAPI.PreCall(2090);
			HalconAPI.Store(proc, 0, windowHandle);
			HalconAPI.Store(proc, 1, row);
			HalconAPI.Store(proc, 2, column);
			HalconAPI.StoreI(proc, 3, button);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(row);
			HalconAPI.UnpinTuple(column);
			string result;
			num = HalconAPI.LoadS(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(windowHandle);
			return result;
		}

		/// <summary>Send an event to a buffer window signaling a mouse drag event.</summary>
		/// <param name="windowHandle">Window handle of the buffer window.</param>
		/// <param name="row">Row coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="column">Column coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="button">Mouse button(s) pressed.</param>
		/// <returns>'true', if HALCON processed the event.</returns>
		// Token: 0x0600050E RID: 1294 RVA: 0x0001D900 File Offset: 0x0001BB00
		public static string SendMouseDragEvent(HWindow windowHandle, int row, int column, int button)
		{
			IntPtr proc = HalconAPI.PreCall(2090);
			HalconAPI.Store(proc, 0, windowHandle);
			HalconAPI.StoreI(proc, 1, row);
			HalconAPI.StoreI(proc, 2, column);
			HalconAPI.StoreI(proc, 3, button);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			string result;
			num = HalconAPI.LoadS(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(windowHandle);
			return result;
		}

		/// <summary>Send an event to a buffer window signaling a mouse up event.</summary>
		/// <param name="windowHandle">Window handle of the buffer window.</param>
		/// <param name="row">Row coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="column">Column coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="button">Mouse button(s) pressed.</param>
		/// <returns>'true', if HALCON processed the event.</returns>
		// Token: 0x0600050F RID: 1295 RVA: 0x0001D960 File Offset: 0x0001BB60
		public static string SendMouseUpEvent(HWindow windowHandle, HTuple row, HTuple column, int button)
		{
			IntPtr proc = HalconAPI.PreCall(2091);
			HalconAPI.Store(proc, 0, windowHandle);
			HalconAPI.Store(proc, 1, row);
			HalconAPI.Store(proc, 2, column);
			HalconAPI.StoreI(proc, 3, button);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(row);
			HalconAPI.UnpinTuple(column);
			string result;
			num = HalconAPI.LoadS(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(windowHandle);
			return result;
		}

		/// <summary>Send an event to a buffer window signaling a mouse up event.</summary>
		/// <param name="windowHandle">Window handle of the buffer window.</param>
		/// <param name="row">Row coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="column">Column coordinate of the mouse cursor in the image coordinate system.</param>
		/// <param name="button">Mouse button(s) pressed.</param>
		/// <returns>'true', if HALCON processed the event.</returns>
		// Token: 0x06000510 RID: 1296 RVA: 0x0001D9CC File Offset: 0x0001BBCC
		public static string SendMouseUpEvent(HWindow windowHandle, int row, int column, int button)
		{
			IntPtr proc = HalconAPI.PreCall(2091);
			HalconAPI.Store(proc, 0, windowHandle);
			HalconAPI.StoreI(proc, 1, row);
			HalconAPI.StoreI(proc, 2, column);
			HalconAPI.StoreI(proc, 3, button);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			string result;
			num = HalconAPI.LoadS(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(windowHandle);
			return result;
		}

		// Token: 0x040000A7 RID: 167
		private HDrawingObject.HDrawingObjectCallback onresize;

		// Token: 0x040000A8 RID: 168
		private HDrawingObject.HDrawingObjectCallback onattach;

		// Token: 0x040000A9 RID: 169
		private HDrawingObject.HDrawingObjectCallback ondetach;

		// Token: 0x040000AA RID: 170
		private HDrawingObject.HDrawingObjectCallback ondrag;

		// Token: 0x040000AB RID: 171
		private HDrawingObject.HDrawingObjectCallback onselect;

		/// <summary>Signature for the drawing object callbacks in managed code.</summary>
		// Token: 0x020000AA RID: 170
		// (Invoke) Token: 0x06002045 RID: 8261
		public delegate void HDrawingObjectCallback(IntPtr drawid, IntPtr windowHandle, string type);

		/// <summary>Signature for the drawing object callbacks in managed code.</summary>
		// Token: 0x020000AB RID: 171
		// (Invoke) Token: 0x06002049 RID: 8265
		public delegate void HDrawingObjectCallbackClass(HDrawingObject drawid, HWindow window, string type);

		// Token: 0x020000AC RID: 172
		public enum HDrawingObjectType
		{
			// Token: 0x040011A9 RID: 4521
			RECTANGLE1,
			// Token: 0x040011AA RID: 4522
			RECTANGLE2,
			// Token: 0x040011AB RID: 4523
			CIRCLE,
			// Token: 0x040011AC RID: 4524
			ELLIPSE,
			// Token: 0x040011AD RID: 4525
			CIRCLE_SECTOR,
			// Token: 0x040011AE RID: 4526
			ELLIPSE_SECTOR,
			// Token: 0x040011AF RID: 4527
			LINE,
			// Token: 0x040011B0 RID: 4528
			XLD_CONTOUR,
			// Token: 0x040011B1 RID: 4529
			TEXT
		}
	}
}
